package com.asl.website.stat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.asl.website.stat.domain.NetWorkStatDTO;
import com.asl.website.sysJoinMain.domain.JoinUsDTO;
import com.asl.website.sysJoinMain.domain.SysJoinMain;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.asl.common.annotation.Log;
import com.asl.common.core.controller.BaseController;
import com.asl.common.core.domain.AjaxResult;
import com.asl.common.enums.BusinessType;
import com.asl.website.stat.domain.BizNetworkStat;
import com.asl.website.stat.service.IBizNetworkStatService;
import com.asl.common.utils.poi.ExcelUtil;
import com.asl.common.core.page.TableDataInfo;

/**
 * 全球网络统计Controller
 * 
 * @author ruoyi
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/stat/stat")
public class BizNetworkStatController extends BaseController
{
    @Autowired
    private IBizNetworkStatService bizNetworkStatService;

    @GetMapping("/content")
    public AjaxResult getJoinUsContentV2(@RequestHeader(value = "Accept-Language", defaultValue = "zh-CN") String acceptLanguage) {
        List<BizNetworkStat> contents = bizNetworkStatService.selectBizNetworkStatList(new BizNetworkStat());
        if (contents.isEmpty()) {
            return AjaxResult.error("未配置页面内容");
        }

        return AjaxResult.success(new NetWorkStatDTO(contents, acceptLanguage));
    }
    /**
     * 查询全球网络统计列表
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizNetworkStat bizNetworkStat)
    {
        startPage();
        List<BizNetworkStat> list = bizNetworkStatService.selectBizNetworkStatList(bizNetworkStat);
        return getDataTable(list);
    }

    /**
     * 导出全球网络统计列表
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:export')")
    @Log(title = "全球网络统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizNetworkStat bizNetworkStat)
    {
        List<BizNetworkStat> list = bizNetworkStatService.selectBizNetworkStatList(bizNetworkStat);
        ExcelUtil<BizNetworkStat> util = new ExcelUtil<BizNetworkStat>(BizNetworkStat.class);
        util.exportExcel(response, list, "全球网络统计数据");
    }

    /**
     * 获取全球网络统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizNetworkStatService.selectBizNetworkStatById(id));
    }

    /**
     * 新增全球网络统计
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:add')")
    @Log(title = "全球网络统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizNetworkStat bizNetworkStat)
    {
        return toAjax(bizNetworkStatService.insertBizNetworkStat(bizNetworkStat));
    }

    /**
     * 修改全球网络统计
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:edit')")
    @Log(title = "全球网络统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizNetworkStat bizNetworkStat)
    {
        return toAjax(bizNetworkStatService.updateBizNetworkStat(bizNetworkStat));
    }

    /**
     * 删除全球网络统计
     */
    @PreAuthorize("@ss.hasPermi('stat:stat:remove')")
    @Log(title = "全球网络统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizNetworkStatService.deleteBizNetworkStatByIds(ids));
    }
}
